﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Simple.Repository.Migrations
{
    public partial class _47 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AlterColumn<string>(
                name: "CreateUserName",
                table: "ParentChildTasksRecord",
                type: "longtext",
                nullable: true,
                comment: "发布人称呼",
                oldClrType: typeof(string),
                oldType: "longtext",
                oldNullable: true,
                oldComment: "发布人姓名")
                .Annotation("MySql:CharSet", "utf8mb4")
                .OldAnnotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.UpdateData(
                table: "FoodMaterials",
                keyColumn: "FoodName",
                keyValue: null,
                column: "FoodName",
                value: "");

            migrationBuilder.AlterColumn<string>(
                name: "FoodName",
                table: "FoodMaterials",
                type: "longtext",
                nullable: false,
                comment: "食物名称",
                oldClrType: typeof(string),
                oldType: "longtext",
                oldNullable: true,
                oldComment: "食物名称")
                .Annotation("MySql:CharSet", "utf8mb4")
                .OldAnnotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "Commodity_Category",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(36)", nullable: false, comment: "主键", collation: "ascii_general_ci"),
                    TypeName = table.Column<string>(type: "longtext", nullable: false, comment: "类型名称")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Remark = table.Column<string>(type: "longtext", nullable: false, comment: "备注")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false, comment: "软删标记"),
                    CreatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "创建时间"),
                    CreatedUserId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "创建用户Id", collation: "ascii_general_ci"),
                    UpdatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "更新时间"),
                    UpdatedUserId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "更新用户Id", collation: "ascii_general_ci"),
                    OrganizationId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "机构Id", collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Commodity_Category", x => x.Id);
                },
                comment: "商品分类")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "Commodity",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(36)", nullable: false, comment: "主键", collation: "ascii_general_ci"),
                    Title = table.Column<string>(type: "longtext", nullable: false, comment: "商品名称/标题")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    IsShow = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "是否上架显示"),
                    StockCount = table.Column<int>(type: "int", nullable: false, comment: "库存"),
                    SoldCount = table.Column<int>(type: "int", nullable: false, comment: "现已卖出多少"),
                    Integral = table.Column<int>(type: "int", nullable: false, comment: "价值积分"),
                    Content = table.Column<string>(type: "longtext", nullable: false, comment: "内容或描述")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    CategoryId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "分类Id", collation: "ascii_general_ci"),
                    IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false, comment: "软删标记"),
                    CreatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "创建时间"),
                    CreatedUserId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "创建用户Id", collation: "ascii_general_ci"),
                    UpdatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "更新时间"),
                    UpdatedUserId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "更新用户Id", collation: "ascii_general_ci"),
                    OrganizationId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "机构Id", collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Commodity", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Commodity_Commodity_Category_CategoryId",
                        column: x => x.CategoryId,
                        principalTable: "Commodity_Category",
                        principalColumn: "Id");
                },
                comment: "商品")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "Commodity_Image",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(36)", nullable: false, comment: "主键", collation: "ascii_general_ci"),
                    FiledId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "文件Id", collation: "ascii_general_ci"),
                    FileName = table.Column<string>(type: "longtext", nullable: false, comment: "文件名称")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    FileSize = table.Column<string>(type: "longtext", nullable: false, comment: "文件大小")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    CommodityId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "商品Id", collation: "ascii_general_ci"),
                    IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false, comment: "软删标记"),
                    CreatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "创建时间"),
                    CreatedUserId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "创建用户Id", collation: "ascii_general_ci"),
                    UpdatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "更新时间"),
                    UpdatedUserId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "更新用户Id", collation: "ascii_general_ci"),
                    OrganizationId = table.Column<Guid>(type: "char(36)", nullable: true, comment: "机构Id", collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Commodity_Image", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Commodity_Image_Commodity_CommodityId",
                        column: x => x.CommodityId,
                        principalTable: "Commodity",
                        principalColumn: "Id");
                },
                comment: "商品图片")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateIndex(
                name: "IX_Commodity_CategoryId",
                table: "Commodity",
                column: "CategoryId");

            migrationBuilder.CreateIndex(
                name: "IX_Commodity_Image_CommodityId",
                table: "Commodity_Image",
                column: "CommodityId");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "Commodity_Image");

            migrationBuilder.DropTable(
                name: "Commodity");

            migrationBuilder.DropTable(
                name: "Commodity_Category");

            migrationBuilder.AlterColumn<string>(
                name: "CreateUserName",
                table: "ParentChildTasksRecord",
                type: "longtext",
                nullable: true,
                comment: "发布人姓名",
                oldClrType: typeof(string),
                oldType: "longtext",
                oldNullable: true,
                oldComment: "发布人称呼")
                .Annotation("MySql:CharSet", "utf8mb4")
                .OldAnnotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AlterColumn<string>(
                name: "FoodName",
                table: "FoodMaterials",
                type: "longtext",
                nullable: true,
                comment: "食物名称",
                oldClrType: typeof(string),
                oldType: "longtext",
                oldComment: "食物名称")
                .Annotation("MySql:CharSet", "utf8mb4")
                .OldAnnotation("MySql:CharSet", "utf8mb4");
        }
    }
}
